package com.kasinf.sample.satoken.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.annotation.SaIgnore;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author : Kaiser
 * @Date: 2025/5/16  11:07
 */
@RestController
@RequestMapping("api")
public class ApiController {

    /**
     * 忽略接口鉴权
     */
    @SaIgnore
    @GetMapping("resource0")
    public String ignored(){
        return "Hello World0";
    }

    /**
     * 只需要登录就能访问
     */
    @GetMapping("resource")
    public String getResource(){
        return "Hello World";
    }

    /**
     * 权限校验
     */
    @SaCheckRole("superAdmin")
    @GetMapping("resource2")
    public String getResource2(){
        return "Hello World2";
    }

    /**
     * 权限校验
     */
    @SaCheckPermission("user:add")
    @GetMapping("resource3")
    public String getResource3(){
        return "Hello World3";
    }
}
